package cn.qihang.ssm.service.impl;

import cn.qihang.ssm.mapper.PermissionMapper;
import cn.qihang.ssm.pojo.Permission;
import cn.qihang.ssm.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: qihang
 * @Date: 2022/11/4 15:26
 * @Desc:
 */
@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionMapper permissionMapper;

    /**
     * 查询所有资源权限
     * @param page
     * @param size
     * @return
     */
    @Override
    public List<Permission> findAll(Integer page, Integer size) {
        return this.permissionMapper.findAll();
    }


    /**
     * 添加资源权限
     */
    @Override
    public void save(Permission permission) {
        this.permissionMapper.save(permission);
    }


    /**
     * 删除资源权限
     * @param id
     */
    @Override
    public void deletePermission(Integer id) {
        //删除Permission关联表role_permission中的数据
        this.permissionMapper.delete_role_permissionById(id);

        //删除Permission表中的数据
        this.permissionMapper.deletePermission(id);
    }
}
